package com.qiwx.pigeon.adapter.produce;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qiwx.pigeon.R;
import com.qiwx.pigeon.Utils.DateTimeUtils;
import com.qiwx.pigeon.Utils.StringUtil;
import com.qiwx.pigeon.adapter.home.ICageInterface;
import com.qiwx.pigeon.data.CageStatusConfig;
import com.qiwx.pigeon.data.vo.CageBean;
import com.qiwx.pigeon.data.vo.CageBeanVo;
import com.qiwx.pigeon.widget.EggView;

import java.util.List;

/**
 * @description
 * @Author qiwx
 * @Date 2020-04-08 11:35
 * 查看空窝
 **/
public class CheckKWAdapter extends BaseQuickAdapter<CageBeanVo, BaseViewHolder> {
    ICageInterface iCageInterface;

    public CheckKWAdapter(int layoutResId, List<CageBeanVo> data) {
        super(layoutResId, data);
    }

    public void setiCageInterface(ICageInterface iCageInterface) {
        this.iCageInterface = iCageInterface;
    }

    @Override
    protected void convert(BaseViewHolder holder, CageBeanVo cageBean) {
        holder.setText(R.id.txt_c_number, "编号: " + cageBean.getNumber() + "");
        holder.setText(R.id.txt_status, "状态:" + "空窝");
        String lastDate = cageBean.getLast_lay_egg_date();
        if (StringUtil.isEmpty(lastDate)) {
            lastDate = "- -月- -日";
        } else {
            lastDate = DateTimeUtils.timeStamp2MDS(lastDate);
        }
        holder.setText(R.id.txt_lay_date, "上次下蛋日期:" + lastDate);
        holder.findView(R.id.btn_opreate).setOnClickListener(v -> {
            if (iCageInterface != null) {
                iCageInterface.onSelectId(holder.getAdapterPosition(), cageBean.getId(), 1);
            }

        });
        holder.findView(R.id.btn_opreation_add_date).setOnClickListener(v -> {
            if (iCageInterface != null) {
                iCageInterface.onSelectId(holder.getAdapterPosition(), cageBean.getId(), 2);
            }
        });


    }
}
